package com.hjm.project.batchSettle.batchSettle.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.batchSettle.batchSettle.domain.BatchSettle;
import com.hjm.project.batchSettle.batchSettle.service.IBatchSettleService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import javax.annotation.Resource;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 兜底结算记录Controller
 * 
 * @author maker-platform
 * @date 2022-03-10
 */
@Controller
@RequestMapping("/batchSettle/batchSettle")
public class BatchSettleController extends BaseController {
    private String prefix = "batchSettle/batchSettle";

    @Resource
    private IBatchSettleService batchSettleService;

    @RequiresPermissions("batchSettle:batchSettle:view")
    @GetMapping()
    public String batchSettle() {
        return prefix + "/batchSettle";
    }

    /**
     * 查询兜底结算记录列表
     */
    @RequiresPermissions("batchSettle:batchSettle:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BatchSettle batchSettle) {
        startPage();
        List<BatchSettle> list = batchSettleService.selectBatchSettleList(batchSettle);
        return getDataTable(list);
    }

    /**
     * 导出兜底结算记录列表
     */
    @RequiresPermissions("batchSettle:batchSettle:export")
    @Log(title = "兜底结算记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BatchSettle batchSettle) {
        List<BatchSettle> list = batchSettleService.selectBatchSettleList(batchSettle);
        ExcelUtil<BatchSettle> util = new ExcelUtil<BatchSettle>(BatchSettle.class);
        return util.exportExcel(list, "batchSettle");
    }

    /**
     * 新增兜底结算记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存兜底结算记录
     */
    @RequiresPermissions("batchSettle:batchSettle:add")
    @Log(title = "兜底结算记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BatchSettle batchSettle) {
        return toAjax(batchSettleService.insertBatchSettle(batchSettle));
    }

    /**
     * 修改兜底结算记录
     */
    @GetMapping("/edit/{settDate}")
    public String edit(@PathVariable("settDate") String settDate, ModelMap mmap) {
        BatchSettle batchSettle = batchSettleService.selectBatchSettleById(settDate);
        mmap.put("batchSettle", batchSettle);
        return prefix + "/edit";
    }

    /**
     * 修改保存兜底结算记录
     */
    @RequiresPermissions("batchSettle:batchSettle:edit")
    @Log(title = "兜底结算记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BatchSettle batchSettle) {
        return toAjax(batchSettleService.updateBatchSettle(batchSettle));
    }

    /**
     * 删除兜底结算记录
     */
    @RequiresPermissions("batchSettle:batchSettle:remove")
    @Log(title = "兜底结算记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(batchSettleService.deleteBatchSettleByIds(ids));
    }
}
